<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>light</title>

</head>
<body>
    <img src="../img/off.gif" id="light" onclick="turnoff()">


    <script type="text/javascript">
        var flag = false;

        var light = document.getElementById("light");

        var turnoff = function () {
            if (flag){
                light.src = "../img/off.gif"
                flag = false;
            }else{
                light.src = "../img/on.gif"
                flag = true;
            }
        }

    </script>
</body>
</html>